﻿#include <iostream>
#include <assert.h>
#include <map>

//字符串格式化整理

#include "StrHelper.h"

class TestPrint
{
public:
    TestPrint()
    {
        std::cout << "TestPrint 构造函数" << std::endl;
    }

    ~TestPrint()
    {
        std::cout << "TestPrint 析构函数" << std::endl;
    }
    friend void operator << (std::iostream& out, const TestPrint& t)
    {
        out << t.val << "_" << t.a ;
    }
private:
    int a = 100;
    std::string val = "hello";
};

int main()
{
    std::string strMsg("my msg");
    std::cout << str::format("this is %s --> %s", strMsg, TestPrint()) << std::endl;

    std::cout << str::format_pos("this is %1 --> %2, this is %1 --> %2", strMsg, TestPrint()) << std::endl;

    std::cout << str::join("123", "456", "789") << std::endl;

    std::cout << str::join<','>("123", "456", "789") << std::endl;

    std::vector<std::string> test= {"3456", "123"};

    std::cout << str::concat(test) << std::endl;

    auto str = str::concat(test);

    auto vecList = str::split(str, ",");
    for(auto item : vecList)
    {
        std::cout << item << std::endl;
    }

    std::vector<int> vecInt = str::split<int>(str, ",");
    for(auto item : vecInt)
    {
        std::cout << item << std::endl;
    }

    std::string s("abcUPabc12345678");

    std::cout << str::to_lower(s) << std::endl;
    std::cout << str::to_lower_c("Hello") << std::endl;


    std::cout << str::replace_all(s, "abc", "haha") << std::endl;

    std::cout << str::cutstr_c(s, "up", "123") << std::endl;
    std::cout << str::cutstr_c(s,  "1235") << std::endl;
    std::cout << str::cutstr_c(s,  "456") << std::endl;


    std::cout << str::cutstr(s, "haha", 4) << std::endl;
    std::cout << s << std::endl;
    std::cout << str::cutstr(s, "haha","456") << std::endl;
    std::cout << s << std::endl;
    return 0;
}